-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] Add XRPL #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Feat] Add XRPL #67
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors the wallet and key management architecture to support multiple chain types beyond EVM (e.g., XRPL native, Solana). The refactoring makes the codebase more modular and chain-agnostic by extracting common wallet operations into a shared chains package.
Changes:
- Changed
SavePrivateKeyinterface from accepting*ecdsa.PrivateKeyto acceptingstringfor chain-agnostic key handling - Moved key management functions (AddKeyByPrivateKey, DeleteKey, ExportPrivateKey, ListKeys, ShowKey, AddRemoteSignerKey) from chain provider implementations to a common
chainspackage - Updated all tests and mocks to reflect the new architecture
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| relayer/wallet/wallet.go | Changed SavePrivateKey signature to accept string instead of *ecdsa.PrivateKey |
| relayer/wallet/geth/wallet.go | Updated implementation to convert hex string to ECDSA key internally |
| relayer/wallet/geth/wallet_test.go | Updated tests to pass hex-encoded private keys |
| relayer/chains/keys.go | New file containing chain-agnostic key management functions |
| relayer/chains/signer.go | New file containing LoadSigners helper function |
| relayer/chains/provider.go | Removed key management methods from KeyProvider interface |
| relayer/chains/evm/keys.go | Simplified to only handle mnemonic-based key generation |
| relayer/chains/evm/signer.go | Simplified to delegate to chains.LoadSigners |
| relayer/chains/evm/keys_test.go | Updated tests to use new chains package functions |
| relayer/chains/signer_test.go | Moved and updated test, changed package name |
| relayer/app.go | Added getWallet helper and updated to use chains package functions |
| relayer/app_test.go | Updated mock expectations to work with new architecture |
| internal/relayertest/mocks/wallet.go | Updated mock SavePrivateKey signature |
| internal/relayertest/mocks/chain_provider.go | Removed key management methods from mock |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
769b441 to
81fddd7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (2)
relayer/chains/xrpl/provider.go:300
- The XRPL implementation lacks test coverage. While EVM chains have comprehensive tests (keys_test.go, provider_test.go, utils_test.go), XRPL has no test files. At minimum, tests should be added for critical functionality like wallet operations (SaveBySecret, SaveByMnemonic, DeleteKey), provider operations (RelayPacket, QueryBalance), and utility functions (stringToHex, parseAssetsFromSignal).
relayer/wallet/xrpl/wallet.go:270 - The XRPL wallet implementation lacks test coverage. Critical wallet operations like SaveBySecret, SaveByMnemonic, SaveRemoteSignerKey, and DeleteKey should have tests similar to the GethWallet test suite to ensure they work correctly and handle edge cases properly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1dc46f7 to
b65571a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 70 out of 71 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
relayer/app_test.go:447
- This test uses
time.Now().Unix()twice when constructing the expected and returned packets; those calls can differ by a second, making the equality assertion flaky. Capture the timestamp once (e.g.,now := time.Now().Unix()) and reuse it for both packets (or assert on fields excludingCreatedAt).
// Create the expected Packet object
tunnelPacketBandInfo := bandtypes.NewPacket(
1,
1,
signalPrices,
signingInfo,
nil,
time.Now().Unix(),
)
// Set up the mock expectation
s.client.EXPECT().
GetTunnelPacket(gomock.Any(), uint64(1), uint64(1)).
Return(tunnelPacketBandInfo, nil)
// Call the function under test
packet, err := s.app.QueryTunnelPacketInfo(context.Background(), 1, 1)
// Create the expected packet structure for comparison
expected := bandtypes.NewPacket(1, 1, signalPrices, signingInfo, nil, time.Now().Unix())
// Assertions
s.Require().NoError(err)
s.Require().Equal(expected, packet)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 69 out of 70 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $mockgen_cmd -source=relayer/chains/xrpl/client.go -mock_names Client=MockXRPLClient -package mocks -destination internal/relayertest/mocks/chain_xrpl_client.go | ||
|
|
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra trailing blank line added at the end of the script. Consider removing it to keep generated diffs clean and avoid linting/formatting noise in shell scripts.
| cmd.Flags().String(flagPrivateKey, "", "add key with the given private key") | ||
| cmd.Flags().String(flagFamilySeed, "", "add key with the given family seed") | ||
| cmd.Flags().String(flagMnemonic, "", "add key with the given mnemonic") | ||
| cmd.Flags().Uint64(flagCoinType, defaultCoinType, "coin type number for HD derivation") | ||
| cmd.Flags().Uint64(flagWalletAccount, 0, "account number in the HD derivation path") |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --coin-type flag defaults to defaultCoinType (60), but this PR introduces XRPL support and App.AddKeyByMnemonic now rejects coin types other than 144 for XRPL. As a result, keys add <xrpl-chain> <key> without explicitly setting --coin-type 144 will fail. Consider defaulting coin type based on the target chain type (after InitTargetChain) or overriding the default to 144 when the chain is XRPL (and update the prompt/flag help accordingly).
| func Uint64StrToHexStr(uint64Str string) (string, error) { | ||
| n := new(big.Int) | ||
| n, ok := n.SetString(uint64Str, 10) | ||
| if !ok { | ||
| return "", fmt.Errorf("invalid numeric string: %s", uint64Str) | ||
| } | ||
|
|
||
| return fmt.Sprintf("%016X", n), nil |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uint64StrToHexStr formats a big.Int with %016X without enforcing that the parsed value is within uint64 (0..2^64-1). If the input is negative or exceeds uint64, this will produce an invalid-width hex string that can break XRPL binary encoding. Consider validating the value fits in uint64 and returning an error otherwise.
| // SaveBySecret imports the ECDSA key into the keystore and writes its signer record. | ||
| func (w *GethWallet) SaveByPrivateKey(name string, secret string) (addr string, err error) { | ||
| // check if the key name exists |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc comment says "SaveBySecret" but the method name is SaveByPrivateKey. Please align the comment with the exported API to avoid confusion in generated docs and when grepping for method behavior.
Fixed: #XXXX
Implementation details
Please ensure the following requirements are met before submitting a pull request:
CHANGELOG_UNRELEASED.mdFiles changedtab in the Github PR explorer)